package com.yang.doctorrecruitment.dao;

import com.yang.doctorrecruitment.utils.DBManager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class UserResumeDAO {
    private static Connection conn;
    public static boolean updataBaseinfo(String baseInfomation,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set BaseInfomation=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,baseInfomation);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }


    public static boolean updataJobIntension(String JobIntension,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set JobIntension=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,JobIntension);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataWorkExperience(String WorkExperience,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set WorkExperience=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,WorkExperience);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataProjectExperience(String ProjectExperience,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set ProjectExperience=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,ProjectExperience);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataEducationExperience(String EducationExperience,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set EducationExperience=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,EducationExperience);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataSchoolSituation(String SchoolSituation,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set SchoolSituation=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,SchoolSituation);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataSkills(String Skills,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set Skills=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,Skills);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataAppend(String Append,String UserID){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set AppendInformation=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,Append);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }

    public static boolean updataExtra(String UserID,String FileAddress){
        conn= DBManager.getconnection();
        ResultSet res=null;
        PreparedStatement statement=null;
        //插入有点问题，更新也有问题就是一开始里面没有任何数据，插入需要罗列出非常多的列
        String sql=" update userresume set ExtraResume=? where UserID=? ";
        try{
            statement=conn.prepareStatement(sql);
            statement.setString(1,FileAddress);
            statement.setString(2,UserID);
            int count=statement.executeUpdate();
            if(count>=1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            DBManager.closeAll(conn,statement,res);
        }
        return false;
    }
}
